# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=cffi
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=1.14.0
pkgrel=2
_revision=694e7139131f
pkgdesc="Foreign Function Interface for Python calling C code (mingw-w64)"
url='https://cffi.readthedocs.io/'
license=('MIT')
arch=('any')
depends=("${MINGW_PACKAGE_PREFIX}-libffi"
         "${MINGW_PACKAGE_PREFIX}-python-pycparser")
makedepends=("${MINGW_PACKAGE_PREFIX}-python-setuptools")
checkdepends=("${MINGW_PACKAGE_PREFIX}-python-pytest-runner")
source=("${_realname}-${pkgver}.tar.bz2::https://bitbucket.org/cffi/cffi/get/v${pkgver}.tar.bz2")
sha256sums=('0d68110af192214284561c4a4758691ad007e796af0f3ba70f66e7b65479a72e')

prepare() {
  cd ${srcdir}
  cp -r cffi-cffi-${_revision} python-build-${CARCH}
}

build() {
  cd "${srcdir}"
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd ${srcdir}/python-build-${CARCH}
  ${MINGW_PREFIX}/bin/python setup.py build
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
  ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} --root="${pkgdir}" --skip-build

  install -D -m644 LICENSE "${pkgdir}${MINGW_PREFIX}"/share/licenses/python-${_realname}/LICENSE
}
